package cmd

import (
	"fmt"

	"gitee.com/zatto/project/tree/master/vblog/api/cmd/start"
	"gitee.com/zatto/project/tree/master/vblog/api/version"
	"github.com/spf13/cobra"
)

// RootCmd功能:
// 1.打印帮助信息
// 2.-v 打印版本信息

var (
	// 是否打印版本信息
	showVersion bool
)

var RootCmd = &cobra.Command{
	Use:     "vblog-api start",
	Short:   "vblog web Services",
	Long:    "博客系统后端服务",
	Example: "vblog-api -v",
	Run: func(cmd *cobra.Command, args []string) {
		if showVersion {
			fmt.Println(version.Short())
			return
		}
		cmd.Help()
	},
}

func init() {
	RootCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "show vblog version")
	RootCmd.AddCommand(start.Cmd)
}
